package com.fingard.dsp.bank.directbank.ceb01;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.fingard.dsp.bank.directbank.bankInterface.IElecBillQuery;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.*;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB001OperBillQryDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB005BillBackQryDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB006BillStateQryDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB008HistoricalBillQryDetail;
import com.fingard.text.StringHelper;
import com.fingard.util.DateHelper;
import com.fingard.xml.XElement;
import com.fingard.xml.XmlTextReader;
import com.fingard.xml.XmlTextWriter;

/**
 * Created by F on 2018/12/29.
 */
public class CEB01ElecBill extends CEB01Base implements IElecBillQuery {
    /**
     * key取操作标志_操作业务，value对应银行以后的业务
     * 例如撤票：key=3_1,value=G_29
     */
    private static Map<String, String> prodNoMap = new HashMap<String, String>();

    static {
//        提交申请	撤销签收	同意签收	拒绝签收
        prodNoMap.put("1_2", "B_29");
        prodNoMap.put("4_2", "B_28");
        prodNoMap.put("2_2", "B_27");
        prodNoMap.put("3_2", "B_26");//承兑
        prodNoMap.put("1_3", "C_29");
        prodNoMap.put("4_3", "C_28");
        prodNoMap.put("2_3", "C_27");
        prodNoMap.put("3_3", "C_26");//提示收票
        prodNoMap.put("1_4", "E_29");
        prodNoMap.put("4_4", "E_28");
        prodNoMap.put("2_4", "E_27");
        prodNoMap.put("3_4", "E_26");//背书转让
        prodNoMap.put("1_5", "O_29");
        prodNoMap.put("4_5", "O_28");
        prodNoMap.put("2_5", "O_27");
        prodNoMap.put("3_5", "O_26");//质押
        prodNoMap.put("2_6", "P_29");
        prodNoMap.put("3_6", "P_28");
        prodNoMap.put("2_6", "P_27");
        prodNoMap.put("3_6", "P_26");//解质押
        prodNoMap.put("1_12", "R_29");
        prodNoMap.put("4_12", "R_28");
        prodNoMap.put("2_12", "R_27");
        prodNoMap.put("3_12", "R_26");//提示付款
        prodNoMap.put("1_10", "F_29");
        prodNoMap.put("4_10", "F_28");
        prodNoMap.put("2_10", "F_27");
        prodNoMap.put("3_10", "F_26");//贴现
        prodNoMap.put("3_1", "G_29");//退票
    }

    @Override
    public RetAtsB001OperBillQry D_OperBill_Query_Req(ReqB001OperBillQry query) throws Exception {
        RetAtsB001OperBillQry retAts = new RetAtsB001OperBillQry(query.reqHeader);
        retAts.respCode = "0";
        retAts.writeBefore();
        query.readRecord();
        try {
            if ("1".equals(query.detail.queryType)) {
                if ("2".equals(query.detail.busiType)) {
                    queryBillWithB2e003040(query, retAts);
                } else if ("3".equals(query.detail.busiType)) {
                    queryBillWithB2e003018(query, retAts);
                } else if ("4".equals(query.detail.busiType) || "12".equals(query.detail.busiType)) {
                    queryBillWithB2e003017(query, retAts);
                } else if ("5".equals(query.detail.busiType)) {
                    queryBillWithB2e003044(query, retAts);
                } else {
                    throw new Exception("不支持该类型的票据查询" + query.detail.busiType);
                }
            } else if ("2".equals(query.detail.queryType)) {
                queryBillWithCancleOrSign(query, retAts);
            } else if ("3".equals(query.detail.queryType) && "1".equals(query.detail.busiType)) {
                queryBillWithB2e003014(query, retAts);
            } else {
                queryBillWithCancleOrSign(query, retAts);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            retAts = new RetAtsB001OperBillQry(query.reqHeader);
            retAts.respCode = "-1";
            retAts.respInfo = ex.getMessage();
            retAts.writeBefore();
        }
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 查回可以提示付款的票据
     *
     * @param query
     * @param retAts
     */
    private void queryBillWithB2e003018(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
        int start = 1;
        int total = 0;
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003018";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//          ClientPatchID	客户端批内序号/客户交易号	是	50	String	参考说明
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//            AcNo	账号	是	30	String	支持授权账户，授权关系由票据系统维护，如上送户名则银企通判别户名是否正确
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//            BillType	票据类型	否	4	String	见数据字典
            String billType;
            if ("1".equals(query.detail.billType)) {
                billType = "AC01";
            } else {
                billType = "AC02";
            }
            xmlWriter.writeElementString("BillType", billType);
//            BillStatus	交付票据状态	否	2	String
            xmlWriter.writeElementString("BillStatus", "1");
//            StartDate	到日期起始日期	否	8	String	YYYYMMDD
            xmlWriter.writeElementString("StartDate", "");
//            EndDate	到期日终止日期	否	8	String	YYYYMMDD
            xmlWriter.writeElementString("EndDate", "");
//            StartNum	起始笔数	是	7	String
            xmlWriter.writeElementString("StartNum", "" + start);
//            QueryNum	查询笔数	是	7	String
            xmlWriter.writeElementString("QueryNum", "50");
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbmsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(returnNum);
                        }
                        while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                            BillId	票据ID	是	20	String
                            detail.busiNo = tmpBkReader.readedXElement.getSingleText("BillId");
//                            BillNo	人行票号	是	30	String
                            detail.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String	AC01-银承 AC02-商承
                            detail.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "EM001" : "EM002";
//                            DueDt	到期日	是	10	String
                            detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("DueDt"));
//                            RemiDate	出票日	否	10	String	出票未完成时为空
                            detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("RemiDate"));
//                            BillMoney	票面金额	是	25	String
                            detail.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            detail.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            detail.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            detail.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	是	20	String
                            detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            detail.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	是	30	String
                            detail.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	是	50	String
                            detail.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	是	20	String
                            detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人/承兑行	是	50	String
                            detail.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptAcct	承兑人账号	否	30	String
                            detail.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行	是	30	String
                            detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                            Conferno	交易合同号	是	30	String
                            detail.contractNo = tmpBkReader.readedXElement.getSingleText("Conferno");
//                            Isendo	是否可转让	是	4	String	EM00-可再转让 EM01-不得转让
                            detail.transFlag = "EM00".equals(tmpBkReader.readedXElement.getSingleText("Isendo")) ? "1" : "0";
//                            BillStatus	票据状态	是	20	String	直接返回中文
                            detail.billStatus = tmpBkReader.readedXElement.getSingleText("BillStatus");
//                            Remark	备注	否	256	String
//                            detail.memo = tmpBkReader.readedXElement.getSingleText("Remark");
                            retAts.writeDetail(detail);
                        }
                    } else {
                        throw new Exception(returnInfo);
                    }

                } else {
                    throw new Exception(tmpSbmsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
    }

    /**
     * 查回可以质押的票据
     *
     * @param query
     * @param retAts
     */
    private void queryBillWithB2e003044(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
        int start = 1;
        int total = 0;
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003040";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//          ClientPatchID	客户端批内序号/客户交易号	是	50	String	参考说明
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//            AcNo	账号	是	30	String	支持授权账户，授权关系由票据系统维护，如上送户名则银企通判别户名是否正确
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//            BillType	票据类型	否	4	String	见数据字典
            String billType;
            if ("1".equals(query.detail.billType)) {
                billType = "AC01";
            } else {
                billType = "AC02";
            }
            xmlWriter.writeElementString("BillType", billType);
//            Acpt	承兑人/承兑行	否	30	String	支持模糊查询
            xmlWriter.writeElementString("Acpt", "");
//            StartMoney	票面起始金额	否	25	String
            xmlWriter.writeElementString("StartMoney", "");
//            EndMoney	票面到期金额	否	25	String
            xmlWriter.writeElementString("EndMoney", "");
//            StartDate	承兑日起始日期	否	8	String	YYYYMMDD
            xmlWriter.writeElementString("StartDate", "");
//            EndDate	承兑日终止日期	否	8	String	YYYYMMDD
            xmlWriter.writeElementString("EndDate", "");
//            StartNum	起始笔数	是	7	String
            xmlWriter.writeElementString("StartNum", "" + start);
//            QueryNum	查询笔数	是	7	String
            xmlWriter.writeElementString("QueryNum", "50");
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbmsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(returnNum);
                        }
                        while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                            BillId	票据ID	是	20	String
                            detail.busiNo = tmpBkReader.readedXElement.getSingleText("BillId");
//                            BillNo	人行票号	是	30	String
                            detail.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String	AC01-银承 AC02-商承
                            detail.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "EM001" : "EM002";
//                            DueDt	到期日	是	10	String
                            detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("DueDt"));
//                            RemiDate	出票日	否	10	String	出票未完成时为空
                            detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("RemiDate"));
//                            BillMoney	票面金额	是	25	String
                            detail.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            detail.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            detail.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            detail.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	是	20	String
                            detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            detail.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	是	30	String
                            detail.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	是	50	String
                            detail.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	是	20	String
                            detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人/承兑行	是	50	String
                            detail.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptAcct	承兑人账号	否	30	String
                            detail.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行	是	30	String
                            detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                            Conferno	交易合同号	是	30	String
                            detail.contractNo = tmpBkReader.readedXElement.getSingleText("Conferno");
//                            Isendo	是否可转让	是	4	String	EM00-可再转让 EM01-不得转让
                            detail.transFlag = "EM00".equals(tmpBkReader.readedXElement.getSingleText("Isendo")) ? "1" : "0";
//                            BillStatus	票据状态	是	20	String	直接返回中文
                            detail.billStatus = tmpBkReader.readedXElement.getSingleText("BillStatus");
//                            Remark	备注	否	256	String
//                            detail.memo = tmpBkReader.readedXElement.getSingleText("Remark");
                            retAts.writeDetail(detail);
                        }
                    } else {
                        throw new Exception(returnInfo);
                    }

                } else {
                    throw new Exception(tmpSbmsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
    }

    /**
     * 查回可以提示承兑的票据
     *
     * @param query
     * @param retAts
     */
    private void queryBillWithB2e003040(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
        int start = 1;
        int total = 0;
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003040";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//          ClientPatchID	客户端批内序号/客户交易号	是	50	String	参考说明
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//            AcNo	账号	是	30	String	支持授权账户，授权关系由票据系统维护，如上送户名则银企通判别户名是否正确
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//            BillType	票据类型	否	4	String	见数据字典
            xmlWriter.writeElementString("BillType", "");
//            CDStatus	承兑状态	是	4	String	见数据字典
            xmlWriter.writeElementString("CDStatus", "1");
//            StartDate	承兑日起始日期	否	8	String	YYYYMMDD
            xmlWriter.writeElementString("StartDate", "");
//            EndDate	承兑日终止日期	否	8	String	YYYYMMDD
            xmlWriter.writeElementString("EndDate", "");
//            StartNum	起始笔数	是	7	String
            xmlWriter.writeElementString("StartNum", "" + start);
//            QueryNum	查询笔数	是	7	String
            xmlWriter.writeElementString("QueryNum", "50");
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbmsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(returnNum);
                        }
                        while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                            BillId	票据ID	是	20	String
                            detail.busiNo = tmpBkReader.readedXElement.getSingleText("BillId");
//                            BillNo	人行票号	是	30	String
                            detail.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String	AC01-银承 AC02-商承
                            detail.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "EM001" : "EM002";
//                            DueDt	到期日	是	10	String
                            detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("DueDt"));
//                            RemiDate	出票日	否	10	String	出票未完成时为空
                            detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("RemiDate"));
//                            BillMoney	票面金额	是	25	String
                            detail.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            detail.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            detail.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            detail.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	是	20	String
                            detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            detail.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	是	30	String
                            detail.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	是	50	String
                            detail.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	是	20	String
                            detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人/承兑行	是	50	String
                            detail.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptAcct	承兑人账号	否	30	String
                            detail.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行	是	30	String
                            detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                            Conferno	交易合同号	是	30	String
                            detail.contractNo = tmpBkReader.readedXElement.getSingleText("Conferno");
//                            Isendo	是否可转让	是	4	String	EM00-可再转让 EM01-不得转让
                            detail.transFlag = "EM00".equals(tmpBkReader.readedXElement.getSingleText("Isendo")) ? "1" : "0";
//                            BillStatus	票据状态	是	20	String	直接返回中文
                            detail.billStatus = tmpBkReader.readedXElement.getSingleText("BillStatus");
//                            Remark	备注	否	256	String
//                            detail.memo = tmpBkReader.readedXElement.getSingleText("Remark");
                            retAts.writeDetail(detail);
                        }
                    } else {
                        throw new Exception(returnInfo);
                    }

                } else {
                    throw new Exception(tmpSbmsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
    }

    /**
     * 查询可以背书和提示付款的票据
     *
     * @param query
     * @param retAts
     */
    private void queryBillWithB2e003017(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
        int start = 1;
        int total = 0;
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003017";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//            ClientPatchID	客户端批内序号/客户交易号	是	50	String
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//            AcNo	账号	是	30	String	支持授权账户，授权关系由票据系统维护，如上送户名则银企通判别户名是否正确
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//            BillType	票据类型	否	4	String	空-全部 AC01-银承 AC02-商承
            String billType;
            if ("1".equals(query.detail.billType)) {
                billType = "AC01";
            } else {
                billType = "AC02";
            }
            xmlWriter.writeElementString("BillType", billType);
//            Status	票据查询状态	是	2	String	见数据字典（目前只支持1、3）
            String status;
            if ("4".equals(query.detail.busiType)) {
                status = "1";
            } else {
                status = "3";
            }
            xmlWriter.writeElementString("Status", status);
//            AcName	出票人名称	否	50	String	可托收时可输入
            xmlWriter.writeElementString("AcName", "");
//            AcName2	承兑人名称	否	50	String	可托收时可输入
            xmlWriter.writeElementString("AcName2", "");
//            IsfreeStauts	提示付款状态	否	2	String	票据查询状态为3时是必输项
            if ("3".equals(status)) {
                if ("1".equals(query.detail.overdueFlag)) {
                    xmlWriter.writeElementString("IsfreeStauts", "1");
                } else {
                    xmlWriter.writeElementString("IsfreeStauts", "2");
                }
            } else {
                xmlWriter.writeElementString("IsfreeStauts", "");
            }
//            StartDate	到日期起始日期	否	8	String	查逾期时为空
            xmlWriter.writeElementString("StartDate", "");
//            EndDate	到期日终止日期	否	8	String	查逾期时为空
            xmlWriter.writeElementString("EndDate", "");
//            StartMoney	票面起始金额	否	25	String
            xmlWriter.writeElementString("StartMoney", "");
//            EndMoney	票面终止金额	否	25	String
            xmlWriter.writeElementString("EndMoney", "");
//            OrderCol	排序字段	否	2	String	见数据字典，默认为到期日降序排列
            xmlWriter.writeElementString("OrderCol", "");
//            StartNum	起始笔数	是	3	String
            xmlWriter.writeElementString("StartNum", "" + start);
//            QueryNum	查询笔数	是	3	String
            xmlWriter.writeElementString("QueryNum", "50");
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbmsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(returnNum);
                        }
                        while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                            BillId	票据ID	是	20	String
                            detail.busiNo = tmpBkReader.readedXElement.getSingleText("BillId");
//                            BillNo	人行票号	是	30	String
                            detail.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String	AC01-银承 AC02-商承
                            detail.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "EM001" : "EM002";
//                            DueDt	到期日	是	10	String
                            detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("DueDt"));
//                            RemiDate	出票日	否	10	String	出票未完成时为空
                            detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("RemiDate"));
//                            BillMoney	票面金额	是	25	String
                            detail.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            detail.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            detail.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            detail.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	是	20	String
                            detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            detail.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	是	30	String
                            detail.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	是	50	String
                            detail.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	是	20	String
                            detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人/承兑行	是	50	String
                            detail.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptAcct	承兑人账号	否	30	String
                            detail.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行	是	30	String
                            detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                            Conferno	交易合同号	是	30	String
                            detail.contractNo = tmpBkReader.readedXElement.getSingleText("Conferno");
//                            Isendo	是否可转让	是	4	String	EM00-可再转让 EM01-不得转让

                            detail.transFlag = "EM00".equals(tmpBkReader.readedXElement.getSingleText("Isendo")) ? "1" : "0";
//                            BillStatus	票据状态	是	20	String	直接返回中文
                            detail.billStatus = tmpBkReader.readedXElement.getSingleText("BillStatus");
//                            Remark	备注	否	256	String
//                            detail.memo = tmpBkReader.readedXElement.getSingleText("Remark");
                            retAts.writeDetail(detail);
                        }
                    } else {
                        throw new Exception(returnInfo);
                    }

                } else {
                    throw new Exception(tmpSbmsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
    }

    /**
     * 查回可以撤票的票据
     *
     * @param query
     * @param retAts
     */
    private void queryBillWithB2e003014(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
        int start = 1;
        int total = 0;
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003014";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");

//            ClientPatchID	客户端批内序号/客户交易号	是	50	String
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//            AcNo	账号	是	30	String	支持授权账户，授权关系由票据系统维护，如上送户名则银企通判别户名是否正确
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//            BillType	票据类型	否	4	String	空-全部 AC01-银承 AC02-商承
            String billType;
            if ("1".equals(query.detail.billType)) {
                billType = "AC01";
            } else {
                billType = "AC02";
            }
            xmlWriter.writeElementString("BillType", billType);
//            StartDate	到日期起始日期	否	8	String
            xmlWriter.writeElementString("StartDate", "");
//            EndDate	到期日终止日期	否	8	String
            xmlWriter.writeElementString("EndDate", "");
//            StartNum	起始笔数	是	3	String
            xmlWriter.writeElementString("StartNum", start + "");
//            QueryNum	查询笔数	是	3	String
            xmlWriter.writeElementString("QueryNum", "50");
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbmsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(returnNum);
                        }
                        while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                            BillId	票据ID	是	20	String
                            detail.busiNo = tmpBkReader.readedXElement.getSingleText("BillId");
//                            BillNo	人行票号	是	30	String
                            detail.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String	AC01-银承 AC02-商承
                            detail.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "EM001" : "EM002";
//                            DueDt	到期日	是	10	String
                            detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("DueDt"));
//                            RemiDate	出票日	否	10	String	出票未完成时为空
                            detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("RemiDate"));
//                            BillMoney	票面金额	是	25	String
                            detail.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            detail.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            detail.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            detail.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	是	20	String
                            detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            detail.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	是	30	String
                            detail.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	是	50	String
                            detail.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	是	20	String
                            detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人/承兑行	是	50	String
                            detail.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptAcct	承兑人账号	否	30	String
                            detail.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行	是	30	String
                            detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                            Conferno	交易合同号	是	30	String
                            detail.contractNo = tmpBkReader.readedXElement.getSingleText("Conferno");
//                            Isendo	是否可转让	是	4	String	EM00-可再转让 EM01-不得转让

                            detail.transFlag = "EM00".equals(tmpBkReader.readedXElement.getSingleText("Isendo")) ? "1" : "0";
//                            BillStatus	票据状态	是	20	String	直接返回中文
                            detail.billStatus = tmpBkReader.readedXElement.getSingleText("BillStatus");
//                            Remark	备注	否	256	String
//                            detail.memo = tmpBkReader.readedXElement.getSingleText("Remark");
                            retAts.writeDetail(detail);
                        }
                    } else {
                        throw new Exception(returnInfo);
                    }

                } else {
                    throw new Exception(tmpSbmsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
    }

    private void queryBillWithCancleOrSign(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
        int start = 1;
        int total = 0;
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003068";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//        ClientPatchID	客户端批内序号/客户交易号	是	50	String	参考说明
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//        AcNo	账号	是	30	String
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//        BillType	票据种类	否	4	String	AC01-银承 AC02-商承 为空=查询全部
            String billType;
            if ("1".equals(query.detail.billType)) {
                billType = "AC01";
            } else {
                billType = "AC02";
            }
            xmlWriter.writeElementString("BillType", billType);
//        BillStatus	业务状态	是	2	String	A1-待签收 A2-可撤销
            String queryType;
            if ("2".equals(query.detail.queryType)) {
                queryType = "A1";
            } else if ("3".equals(query.detail.queryType)) {
                queryType = "A2";
            } else {
                throw new Exception("不支持的操作类型：" + query.detail.queryType);
            }
            xmlWriter.writeElementString("BillStatus", queryType);
//        ProdNo	业务类型	是	3	String	D01-查询所有
            String prodNo;
            switch (Integer.valueOf(query.detail.busiType)) {
                case 2:
                    prodNo = "D02";
                    break;
                case 3:
                    prodNo = "D03";
                    break;
                case 4:
                    prodNo = "D04";
                    break;
                case 5:
                    prodNo = "D05";
                    break;
                case 6:
                    prodNo = "D06";
                    break;
                case 10:
                    prodNo = "D08";
                    break;
                case 11:
                    prodNo = "D08";
                    break;
                case 12:
                    prodNo = "D07";
                    break;
                default:
                    throw new Exception("不支持该类型的操作查询：" + query.detail.busiType);
            }
            xmlWriter.writeElementString("ProdNo", prodNo);
//        D02-承兑
//        D03-提示收票
//        D04-背书转让
//        D05-质押
//        D06-解质押待收
//        D07-提示付付款
//        D08-贴现
//        StartDate	票面到期日起始日期	否	10	String	yyyy-MM-dd
            xmlWriter.writeElementString("StartDate", "");
//        EndDate	票面到期日终止日期	否	10	String	yyyy-MM-dd
            xmlWriter.writeElementString("EndDate", "");
//        BillNo	人行票号	否	30	String
            xmlWriter.writeElementString("BillNo", "");
//        StartNum	起始笔数	是	7	String
            xmlWriter.writeElementString("StartNum", "" + start);
//        QueryNum	查询笔数	是	7	String	不能大于50
            xmlWriter.writeElementString("QueryNum", "50");
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbmsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(returnNum);
                        }
                        while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                            BillId	票据ID	是	20	String
                            detail.busiNo = tmpBkReader.readedXElement.getSingleText("BillId");
//                            BillNo	人行票号	是	30	String
                            detail.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String	AC01-银承 AC02-商承
                            detail.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "EM001" : "EM002";
//                            DueDt	到期日	是	10	String
                            detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("DueDt"));
//                            RemiDate	出票日	否	10	String	出票未完成时为空
                            detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("RemiDate"));
//                            BillMoney	票面金额	是	25	String
                            detail.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            detail.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            detail.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            detail.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	是	20	String
                            detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            detail.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	是	30	String
                            detail.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	是	50	String
                            detail.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	是	20	String
                            detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人/承兑行	是	50	String
                            detail.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptAcct	承兑人账号	否	30	String
                            detail.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行	是	30	String
                            detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                            Conferno	交易合同号	是	30	String
                            detail.contractNo = tmpBkReader.readedXElement.getSingleText("Conferno");
//                            Isendo	是否可转让	是	4	String	EM00-可再转让 EM01-不得转让

                            detail.transFlag = "EM00".equals(tmpBkReader.readedXElement.getSingleText("Isendo")) ? "1" : "0";
//                            BillStatus	票据状态	是	20	String	直接返回中文
                            detail.billStatus = tmpBkReader.readedXElement.getSingleText("BillStatus");
//                            Remark	备注	否	256	String
                            detail.memo = tmpBkReader.readedXElement.getSingleText("Remark");
                            retAts.writeDetail(detail);
                        }
                    } else {
                        throw new Exception(returnInfo);
                    }

                } else {
                    throw new Exception(tmpSbmsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
    }

    @Override
    public RetAtsB002BillTransQry D_B002_BillTrans_Query(ReqB002BillTransQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB004BillFrontQry D_B004_BillFront_Query(ReqB004BillFrontQry query) throws Exception {
        RetAtsB004BillFrontQry retAts = new RetAtsB004BillFrontQry(query.reqHeader);
        retAts.writeStart();
        query.readRecord();
        try {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.batchID = query.reqHeader.transSeqID;
            header.TransCode = "b2e003058";
            header.JnlDateTime = new Date();
            writeCommonHeader_2(xmlWriter, header);
//            TransContent?ReqData
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
            xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
            xmlWriter.writeElementString("BillId", query.detail.busiNo);
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbMsg);
                if (tmpBkReader != null) {
                    String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String resurnMsg = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    if ("0000".equals(returnCode)) {
                        if (tmpBkReader.read("/Transaction/TransContent/RespData")) {
                            retAts.respCode = "0";
                            retAts.respInfo = resurnMsg;
//                            ClientPatchID	银企通子流水号	是	50	String
//                            BillId	票据ID	是	20	String
//                            BillNo	票据号码	是	  30	String
                            retAts.billNo = tmpBkReader.readedXElement.getSingleText("BillNo");
//                            BillType	票据种类	是	4	String
                            retAts.billType = "AC01".equals(tmpBkReader.readedXElement.getSingleText("BillType")) ? "1" : "2";
//                            DueDt	到期日	是	10	String	YYYY-MM-DD
                            retAts.dueDate = tmpBkReader.readedXElement.getSingleText("DueDt");
//                            RemiDate	出票日	否	10	String	YYYY-MM-DD
                            retAts.issDate = tmpBkReader.readedXElement.getSingleText("RemiDate");
//                            BillMoney	票面金额	是	25	String
                            retAts.billAmt = tmpBkReader.readedXElement.getSingleText("BillMoney");
//                            RemiCust	出票人	是	50	String
                            retAts.drawName = tmpBkReader.readedXElement.getSingleText("RemiCust");
//                            RemiAcct	出票人账号	是	30	String
                            retAts.drawAct = tmpBkReader.readedXElement.getSingleText("RemiAcct");
//                            RemiBank	出票人开户行	是	50	String
                            retAts.drawBnkName = tmpBkReader.readedXElement.getSingleText("RemiBank");
//                            RemiBankNo	出票人开户行行号	否	20	String
                            retAts.drawBnkCode = tmpBkReader.readedXElement.getSingleText("RemiBankNo");
//                            Payee	收款人名称	是	50	String
                            retAts.payeeName = tmpBkReader.readedXElement.getSingleText("Payee");
//                            PayeeAcct	收款人账号	否	30	String
                            retAts.payeeAct = tmpBkReader.readedXElement.getSingleText("PayeeAcct");
//                            PayeeBank	收款人开户行	否	50	String
                            retAts.payeeBnkName = tmpBkReader.readedXElement.getSingleText("PayeeBank");
//                            PayeeBankNo	收款人开户行行号	否	20	String
                            retAts.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("PayeeBankNo");
//                            Acpt	承兑人	否	50	String
                            retAts.accpName = tmpBkReader.readedXElement.getSingleText("Acpt");
//                            AcptBank	承兑人开户行名称	否	50	String
                            retAts.accpBnkName = tmpBkReader.readedXElement.getSingleText("AcptBank");
//                            AcptAcct	承兑人账号	否	30	String
                            retAts.accpAct = tmpBkReader.readedXElement.getSingleText("AcptAcct");
//                            AcptBankNo	承兑人开户行行号	否	30	String
                            retAts.accpBnkCode = tmpBkReader.readedXElement.getSingleText("AcptBankNo");
//                             Isendo	是否可转让	是	4	String
                            String transFlag = tmpBkReader.readedXElement.getSingleText("Isendo");
                            if ("EM00".equals(transFlag)) {
                                retAts.transFlag = "1";
                            } else if ("EM01".equals(transFlag)) {
                                retAts.billNo = "0";
                            }
//                            BillStatus	票据状态	是	20	String
                            retAts.billState = tmpBkReader.readedXElement.getSingleText("BillStatus");
                        } else {
                            retAts.respCode = "-1";
                            retAts.respInfo = "无法获取该票据的正面信息";
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = resurnMsg;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = tmpSbMsg.toString();
                }
            } else {
                retAts.respCode = "-1";
                retAts.respInfo = result[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            retAts.respCode = "-1";
//            retAts.respInfo = ex.getMessage();
        }
        //如果正面信息查询异常，直接返回此时的票据状态
        if ("-1".equals(retAts.respCode)) {
            retAts.billState = getBankConfig().getMapValueByKey("billStatuMapping",
                    queryBillStateByB2e003073(query.reqHeader.transSeqID, query.detail.actNum, query.detail.billNo));
            if (StringHelper.hasAnyChar(retAts.billState)) {
                retAts.respCode = "0";
            }
        }
        retAts.writeRetDetail();
        retAts.writeEnd();
        return retAts;
    }

    @Override
    public RetAtsB005BillBackQry D_B005_BillBack_Query(ReqB005BillBackQry query) throws Exception {
        RetAtsB005BillBackQry retAts = new RetAtsB005BillBackQry(query.reqHeader);
        retAts.writeStart();
        String respCode = "";
        String respInfo = "";
        try {
            int start = 1;
            int total = 0;
            do {
                while (query.readRecord()) {
                    XmlTextWriter xmlWriter = new XmlTextWriter();
                    CEB01Header header = new CEB01Header();
                    header.batchID = query.reqHeader.transSeqID;
                    header.TransCode = "b2e003042";
                    header.JnlDateTime = new Date();
                    writeCommonHeader_2(xmlWriter, header);
                    xmlWriter.writeStartElement("TransContent");
                    xmlWriter.writeStartElement("ReqData");
                    xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
                    xmlWriter.writeElementString("BillId", query.detail.busiNo);
                    xmlWriter.writeElementString("AcNo", query.detail.actNum);
                    xmlWriter.writeElementString("StartNum", start + "");
                    xmlWriter.writeElementString("QueryNum", "50");
                    xmlWriter.writeEndDocument();
                    String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);

                    //String[] result=new String[]{"",FileHelper.readFileText("d:\\textRsp1.txt","utf-8")};

                    if (result[0].length() == 0) {
                        StringBuilder tmpSbmsg = new StringBuilder();
                        XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpSbmsg);
                        if (tmpBkReader != null) {
                            String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                            String returnInfo = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                            String returnNum = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                            if ("0000".equals(returnCode)) {
                                if (total == 0) {
                                    total = Integer.valueOf(returnNum);
                                }
                                while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                                    start++;
                                    RetAtsB005BillBackQryDetail detail = new RetAtsB005BillBackQryDetail();
                                    detail.respCode = "0";
                                    detail.respInfo = "";
                                    //电子票据号码
                                    detail.billNo = query.detail.billNo;
                                    //操作代码取值
                                    // 交易类型代码
                                    detail.transCode = getTransCodeToAts(tmpBkReader.readedXElement.getSingleTextNotNull("Title"));
                                    for (int i = 1; i <= 6; i++) {
                                        String field = tmpBkReader.readedXElement.getSingleTextNotNull("Field" + i);
                                        String fieldValue = tmpBkReader.readedXElement.getSingleTextNotNull("Field" + i + "Value");
                                        if ("被保证人名称".equals(field) || "背书人名称".equals(field) || "提示付款人名称".equals(field) || "出质人名称".equals(field)) {
                                            //申请人
                                            detail.applyName = fieldValue;
                                        }
                                        //String field2=tmpBkReader.readedXElement.getSingleTextNotNull("Field2");
                                        if ("保证人名称".equals(field) || "被背书人名称".equals(field) || "质权人名称".equals(field)) {
                                            //接收人
                                            detail.receName = fieldValue;
                                        }
                                        if ("保证日期".equals(field) || "背书日期".equals(field) || "提示付款日期".equals(field) || "出质日期".equals(field)) {
                                            //申请日期
                                            detail.applyDate = fieldValue;
                                        }
                                        if ("不得转让标记".equals(field)) {
                                            //背书转让标识 1-可再转让 0-不得转让
                                            if ("可转让".equals(fieldValue)) {
                                                detail.transFlag = "1";
                                            } else {
                                                detail.transFlag = "0";
                                            }
                                        }
                                        if ("质押解除日期".equals(field)) {
                                            detail.respDate = fieldValue;
                                        }
                                    }
                                    //detail.guarAddr="";//保证人地址
                                    //detail.repOpenDate="";//回购开放日
                                    //detail.repDueDate="";//回购截止日期
                                    //detail.respFlag="";//应答标记 1--签收 2--驳回
                                    //detail.unPayCode="";//拒付理由代码 1--DC00 2--DC01 N--DC0(N-1) 99--DC09
                                    //detail.recourseType="";//1-拒付追索 2-非拒付追索
                                    retAts.writeDetail(detail);
                                }
                            } else {
                                respCode = "-1";
                                respInfo = returnInfo;
                            }
                        } else {
                            respCode = "-1";
                            respInfo = tmpSbmsg.toString();
                        }
                    } else {
                        respCode = "-1";
                        respInfo = result[1];
                    }
                }
            } while (start - 1 < total);
        } catch (Exception e) {
            respCode = "-1";
            respInfo = "查询票据背面信息异常：" + e.getMessage();
            e.printStackTrace();
            WriteBankLogLn("查询票据背面信息异常：" + e.getMessage());
        }
        if ("-1".equals(respCode)) {
            retAts = new RetAtsB005BillBackQry(query.reqHeader);
            retAts.writeStart();
            retAts.writeRespCode(respCode);
            retAts.writeRespCode(respInfo);
        }
        retAts.writeEnd();
        return retAts;
    }

    @Override
    public RetAtsB006BillStateQry D_B006_BillState_Qeury(ReqB006BillStateQry query) throws Exception {
        RetAtsB006BillStateQry retAts = new RetAtsB006BillStateQry(query.reqHeader);
        retAts.writeStart();
        RetAtsB006BillStateQryDetail detail = new RetAtsB006BillStateQryDetail();
        query.readRecord();
        try {
            //SES01=成功、ERR02=失败
            String dealFlag = queryStateByB2e003074(query);
            detail.billNo = query.detail.billNo;
            detail.reqSeqID = query.detail.reqSeqID;
            if ("SES01".equals(dealFlag)) {
                detail.respCode = "0";
//                String tradeState = queryTradeStateByB2e003072(query);
                detail.transState = "SES01";
                detail.payInfoCode = "SES01";
                detail.billState = getBankConfig().getMapValueByKey("billStatuMapping",
                        queryBillStateByB2e003073(query.detail.reqSeqID, query.detail.actNum, query.detail.billNo));
            } else if ("ERR02".equals(dealFlag)) {
                detail.respCode = "0";
                detail.respInfo = "交易失败";
                detail.transState = "ERR02";
                detail.payInfoCode = "ERR02";
            } else {
                throw new Exception("未知的响应码：" + dealFlag);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
            detail.respCode = "-1";
            detail.respInfo = ex.getMessage();
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    private String queryTradeStateByB2e003072(ReqB006BillStateQry query) throws Exception {
        int start = 1;
        int total = 0;
        String filedir = getBankConfig().getValueAsString("SaveOutTranId");
        String outbankid = "";
        for (String filename : new File(filedir).list()) {
            if (filename.contains(query.detail.reqSeqID)) {
                outbankid = filename.split("_")[1];
                break;
            }
        }
        do {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.JnlDateTime = new Date();
            header.batchID = getBatchID();
            header.TransCode = "b2e003072";
            writeCommonHeader_2(xmlWriter, header);
//        报文体（TransContent?ReqData）
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//            ClientPatchID	客户端批内序号/客户交易号	是	50	String
            xmlWriter.writeElementString("ClientPatchID", getBatchID());
//            CifNo	客户号	是	20	String
            xmlWriter.writeElementString("CifNo", bankFront.org);
//            AcNo	账号 是	30	String
            xmlWriter.writeElementString("AcNo", query.detail.actNum);
//            BillType	票据类型 否	4	String	数据字典
            String billType = "";
            if ("1".equals(query.detail.billType)) {
                billType = "AC01";
            } else if ("2".equals(query.detail.billType)) {
                billType = "AC02";
            }
            xmlWriter.writeElementString("BillType", billType);
//            ProdNo	操作类型	否	4	String	支持多选；格式：x|y|z，中间用英语竖线隔开。详见数据字典
            String prodNo = prodNoMap.get(query.detail.operType + "_" + query.detail.busiType);
            if (StringHelper.isNullOrEmpty(prodNo)) {
                throw new Exception("银行不支持该业务的明细查询：" + query.detail.operType + "_" + query.detail.busiType);
            }
            xmlWriter.writeElementString("ProdNo", prodNo);
//            StartDate	交易起始日期	否	10	String	yyyy-MM-dd
            xmlWriter.writeElementString("StartDate", "");
//            EndDate	交易终止日期	否	10	String	yyyy-MM-dd
            xmlWriter.writeElementString("EndDate", "");
//            BillNo 人行票号	否	30	String	交易日期和人行票号必填一项（交易日期:包括交易起始日期和交易终止日期）；可同时上送
            xmlWriter.writeElementString("BillNo", query.detail.billNo);
//            StartNum	起始笔数	是	7	String
            xmlWriter.writeElementString("StartNum", start + "");
//            QueryNum	查询笔数	是	7	String
            xmlWriter.writeElementString("QueryNum", "20");

            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                XmlTextReader tmpSbReader = loadBankRespXmlReader(result[1], tmpSbMsg);
                if (tmpSbReader != null) {
                    String returnCode = tmpSbReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnMsg = tmpSbReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    if ("0000".equals(returnCode)) {
                        if (total == 0) {
                            total = Integer.valueOf(tmpSbReader.getFirstText("/Transaction/TransContent/TotalNum"));
                        }
                        while (tmpSbReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                            start++;
                            String FromAcctNo = tmpSbReader.readedXElement.getSingleText("FromAcctNo");
                            String histId = tmpSbReader.readedXElement.getSingleText("HistId");
                            if (query.detail.actNum.equals(FromAcctNo) && outbankid.equals(histId)) {
                                return tmpSbReader.readedXElement.getSingleText("BillStatus");
                            }
                        }
                    } else {
                        throw new Exception(returnMsg);
                    }

                } else {
                    throw new Exception(tmpSbMsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } while (start - 1 < total);
        return "";
    }

    //查询交易状态
    private String queryBillStateByB2e003073(String clientPatchID, String actNum, String billNo) {
        try {
            XmlTextWriter xmlWriter = new XmlTextWriter();
            CEB01Header header = new CEB01Header();
            header.JnlDateTime = new Date();
            header.batchID = getBatchID();
            header.TransCode = "b2e003073";
            writeCommonHeader_2(xmlWriter, header);
//        报文体（TransContent?ReqData）
            xmlWriter.writeStartElement("TransContent");
            xmlWriter.writeStartElement("ReqData");
//        ClientPatchID	客户端批内序号/客户交易号	是	50	String	参考说明
            xmlWriter.writeElementString("ClientPatchID", clientPatchID);
//        AcNo	账号	是	30	String
            xmlWriter.writeElementString("AcNo", actNum);
//        BillNo	票号	是	30	String
            xmlWriter.writeElementString("BillNo", billNo);
            xmlWriter.writeEndDocument();
            String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
            if (result[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                XmlTextReader tmpSbReader = loadBankRespXmlReader(result[1], tmpSbMsg);
                if (tmpSbReader != null) {
                    String returnCode = tmpSbReader.getFirstText("/Transaction/TransContent/ReturnCode");
                    String returnMsg = tmpSbReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                    if ("0000".equals(returnCode)) {
                        return tmpSbReader.getFirstText("/Transaction/TransContent/RespData/BillStatus");
                    } else {
                        throw new Exception(returnMsg);
                    }
                } else {
                    throw new Exception(tmpSbMsg.toString());
                }
            } else {
                throw new Exception(result[1]);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "";
    }

    //判断申请的操作银行是否正常接收
    private String queryStateByB2e003074(ReqB006BillStateQry query) throws Exception {
        XmlTextWriter xmlWriter = new XmlTextWriter();
        CEB01Header header = new CEB01Header();
        header.JnlDateTime = new Date();
        header.batchID = getBatchID();
        header.TransCode = "b2e003074";
        writeCommonHeader_2(xmlWriter, header);
//        报文体（TransContent?ReqData）
        xmlWriter.writeStartElement("TransContent");
        xmlWriter.writeStartElement("ReqData");
//        ClientPatchID	客户端批内序号/客户交易号	是	50	String	字符串，要求长度<=50，具体格式建议：企业10位客户号+八位日期+八位顺序号
//        如：20038556452006121800000001
        xmlWriter.writeElementString("ClientPatchID", query.reqHeader.transSeqID);
//        ClientBchID	原交易流水号	是	50	String	原交易类交易中的BatchID-交易流水号
        xmlWriter.writeElementString("ClientBchID", query.detail.reqSeqID);
//        ClientPchId	原交易客户端批内序号	是	50	String	原交易类交易中的ClientPatchID-客户端批内序号/客户交易号-
        xmlWriter.writeElementString("ClientPchId", query.detail.reqSeqID);
        xmlWriter.writeEndDocument();
        String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);
        if (result[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            XmlTextReader tmpSbReader = loadBankRespXmlReader(result[1], tmpSbMsg);
            if (tmpSbReader != null) {
                String returnCode = tmpSbReader.getFirstText("/Transaction/TransContent/ReturnCode");
                String returnMsg = tmpSbReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                if ("0000".equals(returnCode)) {
                    return tmpSbReader.getFirstText("/Transaction/TransContent/RespData/DealFlag");
                } else {
                    throw new Exception(returnMsg);
                }
            } else {
                throw new Exception(tmpSbMsg.toString());
            }
        } else {
            throw new Exception(result[1]);
        }
    }

    @Override
    public RetAtsB007BillKzsrQry D_B007_BillKzsr_Query(ReqB007BillKzsrQry query) throws Exception {
        return null;
    }

    /**
     * 历史票据查询
     *
     * @param req_b008
     * @return
     * @throws Exception
     */
    @Override
    public RetAtsB008HistoricalBillQry D_B008_HistoricalBillQuery(ReqB008HistoricalBillQry req_b008) throws Exception {
        RetAtsB008HistoricalBillQry retAts = new RetAtsB008HistoricalBillQry(req_b008.reqHeader);
        req_b008.readRecord();
        retAts.writeBefore();
        try {
            /**
             * 分页循环，发送报文
             */
            int tmpNowReadStart = 1;//起始笔数
            int tmpNowReadNum = 0;//已查询笔数
            Map<String, Integer> tmpTotalNum = new HashMap<String, Integer>();
            while (tmpNowReadNum == 0 || tmpNowReadNum < tmpTotalNum.get("totalCount")) {
                XmlTextWriter xmlWriter = new XmlTextWriter();
                CEB01Header header = new CEB01Header();
                header.JnlDateTime = new Date();
                header.batchID = getBatchID();
                header.TransCode = "b2e003072";
                writeCommonHeader_2(xmlWriter, header);

                xmlWriter.writeStartElement("TransContent");
                xmlWriter.writeStartElement("ReqData");
                xmlWriter.writeElementString("ClientPatchID", req_b008.reqHeader.transSeqID);//客户端批内序号/客户交易号
                xmlWriter.writeElementString("CifNo", bankFront.org);//客户号
                xmlWriter.writeElementString("AcNo", req_b008.detail.actNum);//账号
                xmlWriter.writeElementString("BillType", req_b008.detail.billType.equals("1") ? "AC01" : "AC02");//票据类型 AC01 银行承兑 AC02商业承兑
                xmlWriter.writeElementString("ProdNo", "");//操作类型	 非必输
                String reqStartDate = req_b008.detail.dueDateDown;
                xmlWriter.writeElementString("StartDate", reqStartDate.substring(0, 4) + "-" + reqStartDate.substring(4, 6) + "-" + reqStartDate.substring(6, 8));//交易起始日期
                String reqEndDate = req_b008.detail.dueDateUp;
                xmlWriter.writeElementString("EndDate", reqEndDate.substring(0, 4) + "-" + reqEndDate.substring(4, 6) + "-" + reqEndDate.substring(6, 8));//交易终止日期
                xmlWriter.writeElementString("BillNo", "");//人行票号
                xmlWriter.writeElementString("StartNum", tmpNowReadStart + "");//起始笔数
                xmlWriter.writeElementString("QueryNum", "50");//查询笔数
                xmlWriter.writeEndDocument();

                String[] result = sendToBank_2(xmlWriter.toXmlString(), header.TransCode);

                if (result[0].length() == 0) {
                    StringBuilder tmpBkMsg = new StringBuilder();
                    XmlTextReader tmpBkReader = loadBankRespXmlReader(result[1], tmpBkMsg);
                    if (tmpBkReader != null) {
                        String returnCode = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnCode");
                        String returnMsg = tmpBkReader.getFirstText("/Transaction/TransContent/ReturnMsg");
                        if ("0000".equals(returnCode)) {
                            retAts.respCode = "0";
                            //符合条件的条数，总明细数
                            String totalCount = tmpBkReader.getFirstText("/Transaction/TransContent/TotalNum");
                            if (tmpTotalNum.containsKey("totalCount")) {
                                if (!tmpTotalNum.get("totalCount").equals(Integer.valueOf(totalCount))) {
                                    retAts.respCode = "-1";
                                    retAts.respInfo = "相同条件前后查出来的总数不一致";
                                    break;
                                }
                            } else {
                                if ("0".equals(totalCount)) {
                                    retAts.respCode = "0";
                                    retAts.respInfo = "记录为空";
                                    break;
                                }
                                tmpTotalNum.put("totalCount", Integer.valueOf(totalCount));//记录总条数
                            }
                            int readCount = 0;
                            int RespData = tmpBkReader.countElement("/Transaction/TransContent/BatchRespList/RespData");
                            if (RespData > 0) {
                                while (tmpBkReader.read("/Transaction/TransContent/BatchRespList/RespData")) {
                                    XElement readXElement = tmpBkReader.readedXElement;
                                    RetAtsB008HistoricalBillQryDetail retatsQryDetail = new RetAtsB008HistoricalBillQryDetail();
                                    retatsQryDetail.billNo = readXElement.getSingleText("BillNo");//人行票号
                                    retatsQryDetail.billType = readXElement.getSingleText("BillType").equals("AC01") ? "1" : "2";//票据类型
                                    retatsQryDetail.issDate = readXElement.getSingleText("RemiDate");//出票日
                                    retatsQryDetail.dueDate = readXElement.getSingleText("DueDt");//到期日
                                    retatsQryDetail.billAmt = readXElement.getSingleText("BillMoney");//票据金额
                                    retatsQryDetail.transFlag = readXElement.getSingleText("IsenDo").equals("EM00") ? "1" : "0";//转让标志 EM00可再转让 EM01不得转让
                                    retatsQryDetail.drawName = readXElement.getSingleText("RemiCust");//出票人名称
                                    retatsQryDetail.drawAct = readXElement.getSingleText("RemiAcct");//出票人账号
                                    retatsQryDetail.drawBnkName = readXElement.getSingleText("RemiBank");//出票人开户行名称
                                    retatsQryDetail.drawBnkCode = readXElement.getSingleText("RemiBankNo");//出票人开户行行号
                                    retatsQryDetail.accpName = readXElement.getSingleText("AcptName");//承兑人名称
                                    retatsQryDetail.accpAct = readXElement.getSingleText("AcptAcct");//承兑人账号
                                    retatsQryDetail.accpBnkCode = readXElement.getSingleText("AcptBankNo");//承兑人开户行行号
                                    retatsQryDetail.payeeName = readXElement.getSingleText("Payee");//收票人名称
                                    retatsQryDetail.payeeAct = readXElement.getSingleText("PayeeAcct");//收票人账号
                                    retatsQryDetail.payeeBnkName = readXElement.getSingleText("PayeeBank");//收票人开户行名称
                                    retatsQryDetail.payeeBnkCode = readXElement.getSingleText("PayeeBankNo");//收票人开户行行号
                                    retatsQryDetail.busiNo = readXElement.getSingleText("HistId");//交易明细流水
                                    retatsQryDetail.billStatus = getBankConfig().getMapValueByKey("billStatuMapping", readXElement.getSingleText("BillStatus"));//票据状态
                                    retatsQryDetail.busiType = req_b008.detail.busiType;
                                    retatsQryDetail.queryType = req_b008.detail.queryType;
                                    retAts.writeDetail(retatsQryDetail);
                                    readCount++;
                                }
                                tmpNowReadNum += readCount;//已查询条数
                                if (Integer.parseInt(totalCount) > tmpNowReadNum) {
                                    //总条数大于已查询条数，说明查询了默认条数的明细
                                    if (readCount != 50) {
                                        retAts.respCode = "-1";
                                        retAts.respInfo = "总条数大于已查询条数,统计明细有误";
                                        break;
                                    }
                                }
                                if (Integer.parseInt(totalCount) < tmpNowReadNum) {
                                    //总条数小于已查询条数,说明数据异常
                                    retAts.respCode = "-1";
                                    retAts.respInfo = "总条数小于已查询条数,统计明细有误";
                                    break;
                                }
                                tmpNowReadStart += readCount;//起始笔数
                            } else {
                                retAts.respCode = "-1";
                                retAts.respInfo = "总笔数不为0，但找不到明细节点/BatchRespList/RespData";
                                break;
                            }
                        } else {
                            String errorCode = tmpBkReader.getFirstText("/transaction/ReturnCode");
                            String errorMsg = tmpBkReader.getFirstText("/transaction/ReturnMsg");
                            retAts.respCode = "-1";
                            retAts.respInfo = "查询失败，银行返回错误代码" + errorCode + ",错误信息：" + errorMsg;
                            break;
                        }
                    } else {
                        retAts.respCode = "-1";
                        retAts.respInfo = tmpBkMsg.toString();
                        break;
                    }
                } else {
                    retAts.respCode = "-1";
                    retAts.respInfo = result[1];
                    break;
                }
            }
        } catch (Exception e) {
            retAts.respCode = "-1";
            retAts.respInfo = "历史票据查询出现异常！";
            WriteBankLogLn("历史票据查询出现异常,异常信息：" + e.getMessage());
        }
        retAts.writeAfter();
        return retAts;
    }

    @Override
    public RetAtsB009DrawBillQry D_B009_DrawBillQuery(ReqB009DrawBillQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB010ProtocolStateQry D_B010_ProtocolStateQuery(ReqB010ProtocolStateQry query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB011TransFlagQry D_B011_TransFlagQuery(ReqB011TransFlagQry query) throws Exception {
        return null;
    }
}
